/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.anhndt.audiobook.business;

import com.sun.lwuit.Component;
import com.sun.lwuit.Graphics;
import com.sun.lwuit.plaf.Border;

/**
 *
 * @author Anhndt
 */
public class CustomBorder extends Border {

    public static final int TOP_BOTTOM = 0;
    public static final int TOP = 1;
    public static final int BOTTOM = 2;
    private int color;
    private int thickness;
    private int type = 0;

    public CustomBorder(int borderColor, int thickness, int type) {
        this.color = borderColor;
        this.thickness = thickness;
        this.type = type;
    }

    public void paint(Graphics g, Component com) {
        g.setColor(color);
        int x = com.getX();
        int y = com.getY();
        int width = com.getWidth();
        int height = com.getHeight() - 1;
        for (int iter = 0; iter < thickness; iter++) {
            if (type == TOP) {
                g.drawLine(x, y, width, y);
            } else if (type == BOTTOM) {
                g.drawLine(x, y + height, width, y + height);
            } else {
                g.drawLine(x, y, width, y);
                g.drawLine(x, y + height, width, y + height);
            }
            width -= 2;
            height -= 2;
        }
    }
}
